#include <stdio.h>
#include <string.h>
int main(int argc, char* argv[])
{
    const char* cmd = "ls";
    cmd = argv[1];
    FILE* fp = popen(cmd, "r");
    if(NULL == fp) {
        fprintf(stderr, "popen return NULL.\n");
        return 0;
    }

    #define LEN 1024
    char str[LEN];
    memset(str, 'a', LEN);
    int n = fread(str, 1, LEN-1, fp);
    str[n] = '\0';
    printf("======\n%s\n======\n", str);
    pclose(fp);

    return 0;
}
